package com.tanxin.bill.common.base;

import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.blankj.utilcode.util.BarUtils;
import com.tanxin.bill.R;
import com.tanxin.bill.common.api.Contacts;

/**
 * Created by TANXIN on 2017/7/16.
 */

public abstract class BaseTitleFragment extends BaseFragment {
    protected Toolbar toolbar;
    FrameLayout activityContainer;

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void setBaseView(LayoutInflater inflater, ViewGroup container) {
        rootView = inflater.inflate(R.layout.base_title_activity, container,false);
        activityContainer = rootView.findViewById(R.id.activity_container);
        toolbar = rootView.findViewById(R.id.toolbar);
        activityContainer.addView(inflater.inflate(getContentViewId(), activityContainer, false));

        toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.themeColor));

        //设置沉浸状态栏
        BarUtils.setStatusBarColor(_mActivity, ContextCompat.getColor(getContext(), R.color.themeColor), Contacts.DEFAULT_ALPHA);
        BarUtils.addMarginTopEqualStatusBarHeight(toolbar);

        ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
        ((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationIcon(R.mipmap.base_back_white);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                pop();
            }
        });

    }
}
